<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5shiv.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css"/>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="static/vant/index.css">
    <link rel="stylesheet" href="static/element/index.css">
    <!--[if IE 6]>
    <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>Title</title>

    <style>
        input::-webkit-outer-spin-button,
        input::-webkit-inner-spin-button {
            -webkit-appearance: none;
        }

        input[type='number'] {
            -moz-appearance: textfield;
        }

        .avatar-uploader .el-upload {
            border: 1px dashed #d9d9d9;
            border-radius: 6px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }

        .avatar-uploader .el-upload:hover {
            border-color: #409EFF;
        }

        .avatar-uploader-icon {
            font-size: 28px;
            color: #8c939d;
            width: 138px;
            height: 180px;
            line-height: 180px;
            text-align: center;
        }

        .avatar {
            width: 138px;
            height: 180px;
            display: block;
        }

        .fail .layui-layer-content {
            background-color: brown;
            color: #eee;
            width: 480px;
            height: 30px;
            text-align: center;
        }

        .succeed .layui-layer-content {
            background-color: #0061A8;
            color: #eee;
            width: 480px;
            height: 30px;
            text-align: center;
        }

    </style>
</head>
<body>
<article class="page-container" id="app">
    <div style="height: 92%; width: 100%; overflow: scroll; float: left; overflow-x: hidden;">
        <el-table :data="tableLs" stripe border style="width: 100%" :height="tableHeightL" empty-text="没有数据" :header-cell-style="tableHeaderCellStyleL" :cell-style="tableCellStyleL">
            <el-table-column prop="VALUE01" label="流水号" width="80"></el-table-column>
            <el-table-column prop="VALUE02" label="消费日期" width="190"></el-table-column>
            <el-table-column prop="VALUE03" label="消费金额" width="120"></el-table-column>
            <el-table-column prop="VALUE04" label="消费类别" width="130"></el-table-column>
            <el-table-column label="操作" show-overflow-tooltip>
                <template slot-scope="scope">
                    <el-button type="primary" @click="fDt(scope.row)" size="mini" style="width: 60px">多退</el-button>
                    <el-button type="primary" @click="fSb(scope.row)" size="mini" style="width: 60px">少补</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</article>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="static/axios.min.js"></script>
<script type="text/javascript" src="./static/vue"></script>
<script src="static/vant/vant.min.js"></script>
<script src="static/element/index.js"></script>
<script type="text/javascript">

    let vm = new Vue({
        el: '#app',
        data: {
            tableLs: [],
            tableHeightL: 0,
            lock: false
        },
        methods: {
            fDt(obj) {
                let ls_opid = "${sessionOpid}";
                layer.prompt({
                    formType: 0,
                    value: '',
                    title: '请输入需要多退的金额',
                    maxlength: 4,
                    area: ['300px', '120px'] //自定义文本域宽高
                }, function (value, index, elem) {
                    if (isNaN(value)) {
                        layer.msg('<span style="font-size:26px; line-height: 30px">请输入数字金额</span>', {time: 2000, skin: 'fail'});
                        return;
                    }

                    layer.confirm("请问是否确定多退操作？", {
                        btn: ["确定", "取消"] //按钮
                    }, function () {
                        if (!this.lock) {
                            this.lock = true
                            let self = this
                            let params = new URLSearchParams();
                            params.append('CMD', "ZY");
                            params.append('VALUE01', obj.VALUE01.toString());
                            params.append('VALUE02', value);
                            params.append('VALUE03', ls_opid);
                            params.append('VALUE04', 'DT');
                            axios.post('/f_wscl/com2', params)
                                .then(function (res) {
                                    let {db1} = res.data
                                    if (db1[0].VALUE01 === 'ZZ01') {
                                        layer.msg('<span style="font-size:26px; line-height: 30px">' + db1[0].VALUE02 + '</span>', {time: 2000, skin: 'fail'});
                                    } else if (db1[0].VALUE01 === 'ZZ00') {
                                        layer.msg('<span style="font-size:26px; line-height: 30px">多退冲正操作完毕!</span>', {time: 2000, skin: 'succeed'}, function () {
                                            let index = parent.layer.getFrameIndex(window.name);
                                            parent.fGetinfoEmp()
                                            parent.layer.close(index);
                                        });
                                    }
                                })
                                .catch(function (error) {
                                    layer.msg('<span style="font-size:24px; line-height: 30px">网络异常错误!</span>', {time: 2000, skin: 'fail'});
                                })
                                .finally(function () {
                                    self.lock = false
                                });
                        }
                        //--如下两个备注留着，用来确定是否关闭弹出的界面而不关闭显示流水的列表界面
                        // layer.closeAll('dialog');
                        // layer.close(index);
                    }, function () {
                    });
                });
            },

            fSb(obj) {
                let ls_opid = "${sessionOpid}";
                layer.prompt({
                    formType: 0,
                    value: '',
                    title: '请输入需要少补的金额',
                    maxlength: 4,
                    area: ['300px', '120px'] //自定义文本域宽高
                }, function (value, index, elem) {
                    if (isNaN(value)) {
                        layer.msg('<span style="font-size:26px; line-height: 30px">请输入数字金额</span>', {time: 2000, skin: 'fail'});
                        return;
                    }

                    layer.confirm("请问是否确定少补操作？", {
                        btn: ["确定", "取消"] //按钮
                    }, function () {
                        if (!this.lock) {
                            this.lock = true
                            let self = this
                            let params = new URLSearchParams();
                            params.append('CMD', "ZY");
                            params.append('VALUE01', obj.VALUE01.toString());
                            params.append('VALUE02', value);
                            params.append('VALUE03', ls_opid);
                            params.append('VALUE04', 'SB');
                            axios.post('/f_wscl/com2', params)
                                .then(function (res) {
                                    let {db1} = res.data
                                    if (db1[0].VALUE01 === 'ZZ01') {
                                        layer.msg('<span style="font-size:26px; line-height: 30px">' + db1[0].VALUE02 + '</span>', {time: 2000, skin: 'fail'});
                                    } else if (db1[0].VALUE01 === 'ZZ00') {
                                        layer.msg('<span style="font-size:26px; line-height: 30px">少补冲正操作完毕!</span>', {time: 2000, skin: 'succeed'}, function () {
                                            let index = parent.layer.getFrameIndex(window.name);
                                            parent.fGetinfoEmp()
                                            parent.layer.close(index);
                                        });
                                    }
                                })
                                .catch(function (error) {
                                    layer.msg('<span style="font-size:24px; line-height: 30px">网络异常错误!</span>', {time: 2000, skin: 'fail'});
                                })
                                .finally(function () {
                                    self.lock = false
                                });
                        }
                        //--如下两个备注留着，用来确定是否关闭弹出的界面而不关闭显示流水的列表界面
                        // layer.closeAll('dialog');
                        // layer.close(index);
                    }, function () {
                    });
                });
            },

            fInit(o) {
                this.tableLs = o.tableLs
            },

            fExit() {
                let index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            },

            tableHeaderCellStyleL({row, column, rowIndex, columnIndex}) {
                let cellStyle1;

                cellStyle1 = "color: #fff;" +
                    "background:#4F4F4F;" +
                    "text-align:center;" +
                    "font-size:15px"

                return cellStyle1
            },

            tableCellStyleL({row, column, rowIndex, columnIndex}) {
                let cellStyle1;

                cellStyle1 = "text-align:center;" +
                    "padding:8px 1px 8px;" +
                    "font-size:15px"
                return cellStyle1;
            },
        },

        mounted(){

        },

        created() {
            let windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
            this.tableHeightL = windowHeight - 50;
            window.fInit = this.fInit
        }
    })

    $(document).ajaxComplete(function (event, xhr, settings) {
        //从http头信息取出 在filter定义的sessionstatus，判断是否是 timeout
        if (xhr.getResponseHeader("sessionstatus") === "timeout") {
            //从http头信息取出登录的url ＝ loginPath
            if (xhr.getResponseHeader("loginPath")) {
                window.location.replace(xhr.getResponseHeader("loginPath"));
            }
        }
    });
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>
